﻿using Susha.Models.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Susha.Models.Pages
{
    public class GuestPage
    {
        public GuestPage()
            : this(0) { }

        public GuestPage(Int32 page)
        {
            NewComment = new GuestComment();
            Int32 rowCount = GuestRepository.GetGuestCommentCount();
            if (CommonTools.COMMENTS_PER_GUEST_PAGE * page > rowCount || page < 0)
            {
                page = 0;
            }
            PageNumber = page;
            Comments = GuestRepository.GetComments(PageNumber);

            Prev = PageNumber > 0;
            Next = CommonTools.COMMENTS_PER_GUEST_PAGE * (page + 1) < rowCount && rowCount != 0;
        }

        public GuestComment NewComment { get; set; }
        public IList<GuestComment> Comments { get; set; }
        public Boolean Prev { get; set; }
        public Boolean Next { get; set; }
        public Int32 PageNumber { get; set; }
        public String FalseCaptcha { get; set; }
    }
}